﻿namespace DCHealthCheck {

    #region Usings
    using DCHealthCheck.DomainModel;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text; 
    #endregion

    public class PendingReplicationBuilder {

        #region Members
        private readonly PendingReplication PendingReplication;

        private readonly System.DirectoryServices.ActiveDirectory.ReplicationOperation ReplicationOperation; 
        #endregion

        #region Constructors
        private PendingReplicationBuilder() {
        }

        public PendingReplicationBuilder(
            PendingReplication pendingReplication,
            System.DirectoryServices.ActiveDirectory.ReplicationOperation replicationOperation)
            : this() {
            if (pendingReplication == null) {
                throw new ArgumentNullException("pendingReplication");
            }
            if (replicationOperation == null) {
                throw new ArgumentNullException("replicationOperation");
            }

            this.PendingReplication = pendingReplication;
            this.ReplicationOperation = replicationOperation;
        } 
        #endregion

        #region Methods
        public PendingReplication GetPendingReplications() {
            this.PendingReplication.OperationNumber = this.ReplicationOperation.OperationNumber;
            this.PendingReplication.OperationType = this.ReplicationOperation.OperationType.ToString();
            this.PendingReplication.PartitionName = this.ReplicationOperation.PartitionName;
            this.PendingReplication.Priority = this.ReplicationOperation.Priority;
            this.PendingReplication.SourceServer = this.ReplicationOperation.SourceServer != null ? this.ReplicationOperation.SourceServer : string.Empty;
            this.PendingReplication.TimeEnqueued = this.ReplicationOperation.TimeEnqueued;

            return this.PendingReplication;
        }

        public override string ToString() {
            if (this.PendingReplication != null) {
                return this.PendingReplication.ToString();
            }
            else {
                return string.Empty;
            }
        } 
        #endregion
    }
}
